<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>普通用户登录</h1>
<form action="">
  <input type="text" name="username" placeholder="用户名"><br>
  <input type="password" name="password" placeholder="密码"><br>
  <input type="button" value="登录" @click="login()">
  <input type="button" value="注册"><br>
  <a href="">随便看看</a>
</form>
<!--引入vue-->
<script src="js/vue.js"></script>
<!--引入Axios-->
<script src="js/axios.min.js"></script>
<script>
  let v = new Vue({
    el:"form",
    data:{},
    methods:{
      login:function () {
        let data = new FormData(document.querySelector("form"));
        axios.post("/login",data).then(function (response) {
          if (response.data==1){
            alert("登录成功！");
            location.href="/ctindex.html";
          }else if (response.data==2){
            alert("用户名不存在！")
          }else{
            alert("密码错误！")
          }
        })
      }
    }
  })
</script>



</body>
</html>